// T590313
#include <bits/stdc++.h>

using namespace std;

int n, m;

int solve(vector<vector<char>> &grids)
{
    vector<vector<vector<bool>>> visited(505, vector<vector<bool>>(505, vector<bool>(3, false)));
}

int main()
{
    int T;
    cin >> T;
    while (T--)
    {
        cin >> n >> m;
        getchar();
        vector<vector<char>> grids(505, vector<char>(505, '#'));
        // O, --, |
        for (int i = 0; i < n; ++i)
        {
            for (int j = 0; j < m; ++j)
            {
                grids[i][j] = getchar();
            }
            getchar();
        }
        cout << solve(grids) << endl;
    }
    // system("pause");
    return 0;
}
